<div class='center_form'>
    <div class="center_form_right">
        <div class='center_form_btn_div' onclick='javascript:Common.submit();'>
            <div class='center_form_btn_pic'>
                <img src='<?php echo HttpUtil::baseUrl();?>/images/save.gif'/>
            </div><div class='center_form_btn_text'><?php echo $this->translate("saveBtn"); ?></div>
        </div>
        <div class='center_form_btn_div' onclick='javascript:Common.gotoUrl("<?php echo HttpUtil::baseUrl();?>/acl/admin");'>
            <div class='center_form_btn_pic'>
                <img src='<?php echo HttpUtil::baseUrl();?>/images/cancel.gif'/>
            </div><div class='center_form_btn_text'><?php echo $this->translate("cancelBtn"); ?></div>
        </div>
    </div>
</div>
<div class="clear"></div>
<div class="centerbig_form">
      <div class="center_top"><span class="center_top_title"><?php echo $this->translate("addAdminTitle"); ?></span></div>
      <div class="right_form_content">
            <div class="centerbig_right">
               <div class="form_content">
                    <form action="<?php echo $this->form->getAction(); ?>" method="post">
                        <?php ZendFormUtil::renderElement($this->form->name); ?>
                        <?php ZendFormUtil::renderElement($this->form->password); ?>
                        <?php ZendFormUtil::renderElement($this->form->email); ?>
                        <?php ZendFormUtil::renderElement($this->form->role); ?>
                        <?php
                            $error = ZendFormUtil::renderErrorMessage($this->form->department);
                            if(!empty($error)){
                        ?>
                        <div class="form_line_div">
                            <div class="form_element_label">
                                &nbsp;
                            </div>
                            <div class="form_element">
                                <label class="form_element_error"><?php echo $error;?></label>
                            </div>
                        </div>
                        <div class='clear'></div>
                        <?php
                           }
                        ?>
                                <?php
                                    $selectedDepartment = $this->form->getValue("department");
                                    if(!isset($selectedDepartment)){
                                        $selectedDepartment = array();
                                    }
                                    for($i=0;$i<count($this->departments);$i=$i+3){
                                        $department0 =  isset($this->departments[$i]) ? $this->departments[$i] : null;
                                        $department1 =  isset($this->departments[$i+1]) ? $this->departments[$i] : null;
                                        $department2 =  isset($this->departments[$i+2]) ? $this->departments[$i] : null;
                                 ?>
                        <div class="form_line_div">
                            <div class="form_element_label">
                                <?php
                                    if($i == 0){
                                       echo $this->form->department->getLabel();
                                    }else{
                                       echo '&nbsp;';
                                    }
                                ?>
                            </div>
                            <div class="form_element">
                                 <?php
                                    if(isset($department0)){
                                        $checked = in_array($department0['id'], $selectedDepartment) ? "checked" : "";
                                 ?>
                                 <div style="float:left;width: 140px;">
                                    <label>
                                        <input type="checkbox" value="<?php echo $department0['id']; ?>" name="department[]" <?php echo $checked; ?> />
                                        <?php echo $this->escape($department0['name']); ?>
                                    </label>
                                 </div>
                                 <?php
                                   }
                                 ?>
                                 <?php
                                    if(isset($department1)){
                                        $checked = in_array($department1['id'], $selectedDepartment) ? "checked" : "";
                                 ?>
                                 <div style="float:left;width: 140px;">
                                    <label>
                                        <input type="checkbox" value="<?php echo $department1['id']; ?>" name="department[]" <?php echo $checked; ?> />
                                        <?php echo $this->escape($department1['name']); ?>
                                    </label>
                                 </div>
                                 <?php
                                   }
                                 ?>
                                 <?php
                                    if(isset($department2)){
                                        $checked = in_array($department2['id'], $selectedDepartment) ? "checked" : "";
                                 ?>
                                 <div style="float:left;width: 140px;">
                                    <label>
                                        <input type="checkbox" value="<?php echo $department2['id']; ?>" name="department[]" <?php echo $checked; ?> />
                                        <?php echo $this->escape($department2['name']); ?>
                                    </label>
                                 </div>
                                 <?php
                                   }
                                 ?>
                                </div>
                            </div>
                                 <?php
                                    }
                                ?>
                        <div class='clear'></div>
                    </form>
               </div>
            </div>
      </div>
      <div class='clear'></div>
</div>
<div class='clear'></div>